package smedi.ismedi.mobile.bff.controller.qualityteam;


import com.smedi.ismedi.qualityteam.dto.request.subject.QuerySubjectPageRequest;
import com.smedi.ismedi.qualityteam.dto.request.subject.SubjectRequest;
import com.smedi.ismedi.qualityteam.dto.response.subject.SubjectDetailResponse;
import com.smedi.ismedi.qualityteam.dto.response.subject.SubjectResponse;
import com.smedi.ismedi.qualityteam.feign.RemoteSubjectFeignApi;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import smedi.ismedi.mobile.bff.controller.BaseController;

import java.util.List;

/**
 * @Author nyl
 * @Date 2021/6/17 9:40
 */
@Api(tags = {"活动课题接口"})
@Slf4j
@RequestMapping(value = "/mobilebff/v1/subject")
@RestController
@RequiredArgsConstructor
public class SubjectController extends BaseController {
    private final RemoteSubjectFeignApi remoteSubjectFeignApi;

    @ApiOperation(value = "活动课题 新增", nickname = "活动课题 新增")
    @PostMapping(value = "/add")
    public ResponseData<SubjectResponse> addSubject(@Validated @RequestBody SubjectRequest subjectRequest) {

        return remoteSubjectFeignApi.addSubject(subjectRequest);
    }

    /**
     * 活动小组详情查询
     *
     * @param subjectId
     * @return
     */
    @ApiOperation(value = "活动课题详情查询", nickname = "活动课题详情查询")
    @GetMapping(value = "/searchSubjectDetail")
    ResponseData<SubjectDetailResponse> searchSubjectDetail(@RequestParam("subjectId") Long subjectId) {

        return remoteSubjectFeignApi.searchSubjectDetail(subjectId);
    }
    /**
     * 获取活动课题 列表通过课题id
     * */
    @ApiOperation(value = "获取活动课题 列表通过小组id", nickname = "获取活动课题 列表通过小组id")
    @GetMapping("/subject/list/teamId")
    ResponseData<List<SubjectResponse>> searchSubjectList(@RequestParam("teamId") Long teamId) {
        return remoteSubjectFeignApi.searchSubjectList(teamId);

    }
    /**
     * 获取活动课题 分页
     * */
    @ApiOperation(value = "获取活动课题 分页", nickname = "获取活动课题 分页")
    @PostMapping("/page")
    ResponseData<PaginationData<SubjectDetailResponse>> getSubjectPage(@Validated @RequestBody QuerySubjectPageRequest querySubjectPageRequest) {
        return remoteSubjectFeignApi.getSubjectPage(querySubjectPageRequest);

    }
}
